home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / AlexNeXTSTEPSource / Source / Chapter6_Events / DelegateDemo / WindowDelegate.m < prev   
Text File  |  1995-06-12  |  709b  |  40 lines

  1. #import <appkit/appkit.h>
  2. #import "WindowDelegate.h"
  3.  
  4. #define    SAVE    NX_ALERTDEFAULT
  5. #define    CLOSE    NX_ALERTALTERNATE
  6. #define    CANCEL    NX_ALERTOTHER
  7.  
  8. @implementation WindowDelegate
  9.  
  10. - windowWillClose:sender
  11. {
  12.     int result;
  13.     result = NXRunAlertPanel
  14.         ([NXApp appName],
  15.         "Unsaved changes. Close Anyway?\n",
  16.         "Save",
  17.         "Close anyway",
  18.         "Cancel");
  19.  
  20.     switch(result)
  21.         {
  22.         case SAVE:
  23.             printf("Save button selected\n");
  24.             printf("Saving...\n");
  25.             printf("Closing window\n\n");
  26.             break;
  27.         case CLOSE:
  28.             printf("Close button selected\n");
  29.             printf("Closing window\n\n");
  30.             break;
  31.         case CANCEL:
  32.             printf("Cancel button selected\n");
  33.             printf("Window won't close\n\n");
  34.             return nil;
  35.         }
  36.     return self;
  37. }
  38.  
  39. @end
  40.